package com.inboyu.application.request;

import com.inboyu.operation.domain.CertificateType;
import com.inboyu.operation.domain.Customer;
import com.inboyu.operation.domain.CustomerId;
import com.inboyu.operation.domain.UserId;
import lombok.Data;

/**
 * 租赁人实体
 */
@Data
public class CustomerCommand {

    /**
     * 运营商id
     */
    private String operationCompanyId;

    /**
     * 用户id
     */
    private String userId;

    /**
     * 租赁人id
     */
    private String customerId;

    /**
     * 租赁人姓名
     */
    private String name;

    /**
     * 租赁人手机号
     */
    private String mobile;

    /**
     * 证件类型
     */
    private String certificateType;

    /**
     * 证件号码
     */
    private String certificateNumber;

    public static Customer toLeaseEntity(CustomerCommand customerCommand) {
        Customer customer = new Customer();
        customer.setCertificateNumber(customerCommand.getOperationCompanyId());
        customer.setUserId(new UserId(customerCommand.getUserId()));
        customer.setId(new CustomerId(customerCommand.getCustomerId()));
        customer.setName(customerCommand.getName());
        customer.setMobile(customerCommand.getMobile());
        customer.setCertificateType(new CertificateType(customerCommand.getCertificateType(), ""));
        customer.setCertificateNumber(customerCommand.getCertificateNumber());
        return customer;
    }
}
